package com.BraveY.Demo10;

public class Student implements Comparable<Student> {
    private int id;
    private String name;
    private int age;
    private String sex;

    public Student() {
    }

    public Student(int id, String name, int age, String sex) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                '}';
    }


    @Override
    public int compareTo(Student o) {
        int result = this.id - o.id;
        result = result == 0 ? this.name.compareTo(o.getName()) : result;
        result = result == 0 ? this.age - o.age : result;
        result = result == 0? this.sex.compareTo(o.getSex()): result;
        return result;
    }
}
